package com.holyant.goods.enums;

import java.util.Arrays;
import java.util.stream.Collectors;

/**辅助单位枚举
 * @author zgx
 * @Title:
 * @Package
 * @Description:
 * @date 2022/5/7 13:06
 */
public enum AssistUnitEnum {
    /** 箱 */
    TRUNK(10, "箱"),
    /** 套 */
    SETOF(15, "套"),
    /** 组 */
    GROUP(20, "组"),
    /** 拖 */
    DRAG(30, "拖"),
    /** 罐 */
    TANK(40, "罐"),
    /** 袋 */
    BAG(50, "袋"),
    /** 包 */
    PACKAGE(60, "包"),
    /** 瓶 */
    BOTTLE(70, "瓶"),
    /** 盒 */
    BOX(80, "盒"),
    /** 支 */
    DIVISION(90, "支");

    private final Integer code;
    private final String name;

    AssistUnitEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }

    public Integer getCode()
    {
        return code;
    }

    public String getName()
    {
        return name;
    }

    public static Integer getCodeByName(String name) {
        for (AssistUnitEnum item : AssistUnitEnum.values()) {
            if (item.getName().equals(name)) {
                return item.code;
            }
        }
        return null;
    }



    public static String getNames() {
        return Arrays.stream(AssistUnitEnum.values()).map(AssistUnitEnum::getName).collect(Collectors.toList()).toString();
    }
}
